﻿@using McsWeb.Models;
@{
    var entity = ViewBag.users as UsersModel;
    Layout = null;
}

<!DOCTYPE html>


<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <link href="~/Content/Css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="~/Content/Css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="~/Content/Css/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
    <link href="~/Content/Css/animate.css" rel="stylesheet">
    <link href="~/Content/Css/style.css?v=4.1.0" rel="stylesheet">
    <title>Insert</title>
    <link href="/Content/Css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="~/Content/common.css" rel="stylesheet">
    <link href="~/Content/Css/plugins/multiselect/bootstrap-multiselect.css" rel="stylesheet" />
    <style>
        /*.col-sm-1, .col-sm-2, .col-sm-3, .col-sm-4, .col-sm-5, .col-sm-6, .col-sm-7, .col-sm-8, .col-sm-9, .col-sm-10, .col-sm-11, .col-sm-12,
        .col-xs-1, .col-xs-2, .col-xs-3, .col-xs-4, .col-xs-5, .col-xs-6, .col-xs-7, .col-xs-8, .col-xs-9, .col-xs-10, .col-xs-11, .col-xs-12,
        .btn-group, #commissionBtn, #clone {
            border-style: solid;
            border-width: 1px;
            border-color: #000;
        }*/
        #RoleIDLaber {
            padding: 8px 0 0 0;
        }

        .padding {
            padding: 0 0 0 0;
        }
    </style>
</head>
<body>
    <div class="wrapper wrapper-content animated fadeInRight">
        <form class="form-horizontal m-t" id="mainForm">

            <input type="hidden" id="ID" name="ID" value=@entity.ID />
            <input type="hidden" id="editStaffID" name="editStaffID" value=@entity.StaffID />

            <div class="form-group">
                <label class="col-xs-2 control-label padding">客户经理：</label>
                <div class="col-xs-10">
                    <select id="StaffID" class="form-control input-sm" name="StaffID" style="padding:0px;padding-left:10px;height:37px;" value="@entity.StaffID">
                        <option value="0" selected="selected">全部</option>
                    </select>
                    <span class="help-block m-b-none" id="SoftwareIDSpan"><i class="fa fa-info-circle"></i>请选择客户经理</span>
                </div>
            </div>

            <div class="row">
                <div class="col-sm-12">
                    <div class="form-group" style="margin-bottom:0px;padding-top:20px">
                        <div class="col-xs-3">
                        </div>
                        <div class="col-xs-9">
                            <button id="submit" class="btn btn-primary pull-right" type="submit">
                                <i class="fa fa-check"></i>&nbsp;提&nbsp;交
                            </button>
                        </div>
                    </div>
                </div>
            </div>
        </form>
    </div>


    <!-- 全局js -->
    <script type="text/javascript" src="~/Scripts/jquery.min.js?v=2.1.4"></script>
    <script type="text/javascript" src="~/Scripts/bootstrap.min.js?v=3.3.6"></script>
    <!-- jQuery Validation plugin javascript-->
    <script type="text/javascript" src="~/Scripts/plugins/validate/jquery.validate.min.js"></script>
    <script type="text/javascript" src="~/Scripts/plugins/validate/messages_zh.min.js"></script>
    <script type="text/javascript" src="~/Scripts/Extensions/ExtValidator.js"></script>

    <!-- layer javascript -->
    <script type="text/javascript" src="~/Scripts/plugins/layer/layer.min.js"></script>
    <script src="/Scripts/plugins/iCheck/icheck.min.js"></script>

    <script src="~/Scripts/plugins/multiselect/bootstrap-multiselect.js"></script>

    <script type="text/javascript">
        $(function () {
            GetSoftwares();
            // validate signup form on keyup and submit
            var icon = "<i class='fa fa-times-circle'></i> ";
            $('.i-checks').iCheck({
                checkboxClass: 'icheckbox_square-green',
                radioClass: 'iradio_square-green',
            });

            var icon = "<i class='fa fa-times-circle'></i> ";
            var validator = $("#mainForm").validate({
                rules: {
                    Name: { required: true, },
                    Phone: { required: true, },
                },
                messages: {
                    Name: { required: icon + "请填写姓名", },
                    Phone: { required: icon + "请填写电话", },
                },
                submitHandler: function (form) {
                    $.ajax({
                        url: "/Home/UsersUpdateAsync",
                        type: "post",
                        dataType: "json",
                        data: $('#mainForm').serialize(),
                        success: function (data) {
                            //Info,Success,Warning,Error
                            var type = data.type;
                            if (type == 1) {
                                layer.msg(data.content, { icon: 6, time: 2000 },
                                    function () {
                                        var index = parent.layer.getFrameIndex(window.name);
                                        parent.layer.close(index);
                                    });

                            } else {
                                layer.msg(data.content, { icon: 5, time: 2000 });
                            }
                        }
                    });
                }
            });
        });
        function GetSoftwares() {
            $.getJSON("/Home/GetStaffId",
                function (data) {
                    $("#StaffID").empty();//清空城市SELECT控件
                    $("<option></option>").val("0").text("全部").appendTo($("#StaffID"));
                    $.each(data, function (i, item) {
                        if (item["ID"] == $("#editStaffID").val()) {
                            console.log($("#editStaffID").val());
                            $("<option></option>").val(item["ID"]).text(item["Name"]).attr("selected", true).appendTo($("#StaffID"));
                        }
                        else {
                            $("<option></option>").val(item["ID"]).text(item["Name"]).appendTo($("#StaffID"));
                        }

                    })
                });
        }
    </script>
</body>
</html>
